home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX 6.5 Applications 1998 June
/
SGI IRIX 6.5 Applications 1998 June.iso
/
dist
/
appletalk.idb
/
usr
/
etc
/
appletalk
/
atinit.z
/
atinit
Wrap
Text File
|
1998-04-27
|
3KB
|
163 lines
#! /bin/csh -f
#
#
# Copyright (c) 1985, 1992
# by Xinet Inc. All Rights Reserved.
# @(#)atinit.sh 8.4 97/03/04 Xinet
#
#script to start, stop, or restart appletalk servers
set path=( /usr/etc/appletalk /bin /usr/{bin,etc,bsd,ucb,sbin} /etc )
set p=$0
set p=$p[1]:t
if ( $#argv < 1 ) then
echo "Usage: $p [start | halt | restart]"
exit 1
endif
if (-x /bin/id) then
if (`/bin/id | grep -c uid=0` > 0) then
set me=root
else
set me=notroot
endif
else
set me=`whoami`
endif
if ("$me" != root) then
echo "You must have root privileges to run this script"
exit 1
endif
set CONF_PATH=/usr/etc/appletalk
set SERVICES=$CONF_PATH/services
set ADM_PATH=/usr/adm/appletalk
set NBP_PID=$ADM_PATH/nbp_pid
set AT_PIDS=$ADM_PATH/nbpreg_pids
set TMPA=/tmp/atinitA$$
foreach arg ($*)
#evaluate any arguments that assign a value:
echo $arg | grep -s '='
if ($status == 0) then
eval set $arg
endif
end
set SERVERS=()
if (-f $SERVICES) then
set SERVERS=(`grep -v '#' $SERVICES | awk '{print $1}'`)
endif
#if no services, then done:
if ($#SERVERS == 0) then
exit 0
endif
switch ($1)
case start:
case halt:
case restart:
set action=$1
breaksw
case START:
set action=start
breaksw
case HALT:
set action=halt
breaksw
case RESTART:
set action=restart
breaksw
default:
echo "Usage: $p [start | halt | restart]"
exit 1
breaksw
endsw
#kill servers if halt or restart:
if ($action == halt|| $action == restart) then
if (-f $NBP_PID) then
cat $NBP_PID
echo " nbpd"
cat $AT_PIDS
set nbppid=`awk '{print $1}' $NBP_PID`
set atpids=`awk '{print $1}' $AT_PIDS`
if ($#atpids > 0) then
echo Killing $atpids
foreach atp ($atpids)
(kill $atp >& /dev/null)
#NOTE: kill executed in sub-shell to prevent us
# from exiting on error (kill is a csh builtin)
end
sleep 1
foreach atp ($atpids)
(kill $atp >& /dev/null)
#NOTE: kill executed in sub-shell to prevent us
# from exiting on error (kill is a csh builtin)
end
sleep 2
foreach atp ($atpids)
#just to make sure:
(kill -9 $atp >& /dev/null)
end
endif
if ($#nbppid > 0) then
#kill nbpd last, so other servers can de-register:
echo Killing nbpd server $nbppid
(kill $nbppid >& /dev/null)
endif
else
echo "AppleTalk services already halted..."
endif
endif
if ($action == halt) then
#done, exit normally
${CONF_PATH}/atconfig -clear
exit 0
endif
#if we are restarting, we clear the interface and sleep to let routes re-build
if ($action == restart) then
echo "Clearing AppleTalk configuration (takes 10 seconds)"
${CONF_PATH}/atconfig -clear
sleep 10
awk -F\ '$2 != "R" {print}' $SERVICES > $TMPA
else
awk -F\ '{print $1}' $SERVICES > $TMPA
#clear the log file on start but not restart
if (-e /usr/adm/appletalk/at_log) then
rm -f /usr/adm/appletalk/at_log.old
mv /usr/adm/appletalk/at_log /usr/adm/appletalk/at_log.old
touch /usr/adm/appletalk/at_log
chmod 666 /usr/adm/appletalk/at_log
else if (-e /var/adm/appletalk/at_log) then
rm -f /var/adm/appletalk/at_log.old
mv /var/adm/appletak/at_log /var/adm/appletalk/at_log.old
touch /var/adm/appletalk/at_log
chmod 666 /usr/adm/appletalk/at_log
endif
endif
set SERVICES=$TMPA
set SERVERS=(`grep -v '#' $SERVICES | awk '{print $1}'`)
echo -n "AppleTalk Services: "
foreach srvr ($SERVERS)
if (-x $srvr) then
#list server:
echo -n " $srvr:t"
endif
end
echo .
csh -fe $SERVICES
set x=$status
rm -f $TMPA
exit $x